<?php
$path = $_GET['path'];
$url = "http://admin:admin@192.168.1.87:8080/alfresco/s/cmis" . $path;
$ch = curl_init();
$file = file_get_contents("./create.atom.xml");
$content = $HTTP_RAW_POST_DATA;
$file = str_replace("%filename%","",$file);
$file = str_replace("%content%",$content,$file);
$file = str_replace("%summary%","my test",$file);
$putData = tmpfile();
fwrite($putData, $content);
fseek($putData, 0);

curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_PUT,1);
//curl_setopt($ch,CURLOPT_POSTFIELDS,$file);
curl_setopt($ch, CURLOPT_INFILE, $putData);
curl_setopt($ch, CURLOPT_INFILESIZE, strlen($content));
curl_setopt($ch,CURLOPT_HTTPHEADER,array("Content-Type: application/atom+xml"));
curl_setopt($ch,CURLOPT_VERBOSE,1);
curl_setopt($ch,CURLOPT_URL,$url);
$result = curl_exec($ch);
curl_close($ch);
header('OK', true, 201);
  // This is sent to save.js and ends up in the result variable.
echo "Ok";
?>
